package com.yyoa.model;

import java.util.List;

import net.sf.json.JSONObject;

public class Filters {

	private String groupOp;

	private List<Rule> rules;

	public Filters() {
	}

	public Filters(String groupOp, List<Rule> rules) {
		this.groupOp = groupOp;
		this.rules = rules;
	}

	public static Filters jsonToBean(String jsonString) {
		return (Filters) JSONObject.toBean(JSONObject.fromObject(jsonString),
				Filters.class);
	}

	public String getGroupOp() {
		return groupOp;
	}

	public void setGroupOp(String groupOp) {
		this.groupOp = groupOp;
	}

	public List<Rule> getRules() {
		return rules;
	}

	public void setRules(List<Rule> rules) {
		this.rules = rules;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((groupOp == null) ? 0 : groupOp.hashCode());
		result = prime * result + ((rules == null) ? 0 : rules.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Filters other = (Filters) obj;
		if (groupOp == null) {
			if (other.groupOp != null)
				return false;
		} else if (!groupOp.equals(other.groupOp))
			return false;
		if (rules == null) {
			if (other.rules != null)
				return false;
		} else if (!rules.equals(other.rules))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Filters [groupOp=" + groupOp + ", rules=" + rules + "]";
	}
}
